package com.mdc.mansion.web.modules.report;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.mdc.mansion.core.modules.restaurant.RestaurantService;
import com.mdc.mansion.dataaccess.modules.restaurant.entity.Restaurant;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.mdc.mansion.core.modules.order.RestaurantOrderService;
import com.mdc.mansion.dataaccess.modules.basedata.entity.RestaurantOrderDTO;
import com.mdc.mansion.dataaccess.modules.order.entity.RestaurantOrder;
import com.mdc.mansion.web.common.web.BaseController;
/**
 * 餐厅报表Controller
 * @author mingdongc
 * @version 2018-01-01
 */
@Controller
@RequestMapping(value = "${adminPath}/report/report")
public class RestaurantReportController extends BaseController {

	@Autowired
	private RestaurantOrderService restaurantOrderService;

	@Autowired
	private RestaurantService restaurantService;

	@RequestMapping(value = "haoheyReport")
	public ModelAndView haoheyReport(RestaurantOrderDTO restaurantOrderDTO) {
		Map<String, Object> model=new HashMap<String, Object>();
		
		if(RestaurantOrderDTO.REPORT_TYPE.ALL.getVal().equals(restaurantOrderDTO.getReportType()))
		{
			List< RestaurantOrderDTO> restaurantList = restaurantOrderService.findrestaurantCount(restaurantOrderDTO);
			List<RestaurantOrderDTO> staffList = restaurantOrderService.findStaffCount(restaurantOrderDTO);
			List<RestaurantOrderDTO> orderList = restaurantOrderService.findOrderCount(restaurantOrderDTO);
			model.put("restaurantList", restaurantList);
			model.put("staffList", staffList);
			model.put("orderList", orderList);
		}else if(RestaurantOrderDTO.REPORT_TYPE.ONE.getVal().equals(restaurantOrderDTO.getReportType()))
		{
			////统计单个店铺任意时间段内按天销售金额、订单量，单个店铺、单日菜品(分类)消费情况
			List< RestaurantOrderDTO> totalAmountList = restaurantOrderService.getTotalAmountList(restaurantOrderDTO);
			List<RestaurantOrderDTO> categoryAmountList = restaurantOrderService.getCategoryAmountList(restaurantOrderDTO);
			List<RestaurantOrderDTO> dishesAmountList = restaurantOrderService.getDishesAmountList(restaurantOrderDTO);
			model.put("totalAmountList", totalAmountList);
			model.put("categoryAmountList", categoryAmountList);
			model.put("dishesAmountList", dishesAmountList);
		}
		List<Restaurant> list = restaurantService.findList(new Restaurant());
		model.put("restaurants",list);
		
		ModelAndView modelAndView=new ModelAndView("modules/report/haoHeyReportList", model);
		return modelAndView;
	}
	
	
	
	
	@RequestMapping(value = "getSummaryByOne")
	public ModelAndView getReportByRes(RestaurantOrder restaurantOrder) {
		Map<String, Object> model=new HashMap<String, Object>();
		List<Restaurant> list = restaurantService.findList(new Restaurant());
		model.put("restaurants",list);
		ModelAndView modelAndView=new ModelAndView("modules/report/haoHeyReportList", null);
		return modelAndView;
	}
	
	
}
